#include "Guardsman.h"
#include "EntityNames.h"

#include <iomanip>

//returns attack damage to deal
int Guardsman::Attack()
{
	//random number
	int random = rand()%10;

	if((random % 5) == 0)
	{
		SpecialTaunt();
		cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Guard) << " is using Special Attack..." << endl;
		//do special
		return ((int)(attack * 1.5));
	}
	else
	{
		Taunt();
		//do normal attack
		return attack;
	}
	
}

//determines how much damage is recieved from attack
//returns true if enemy has been killed
bool Guardsman::Damage(int x)
{
	int damage;

	//calculate damage
	if(x <= defense)
	{
		damage = rand()%5;
	}
	else
	{
		damage = (x - defense) + rand()%5;
	}
	//calculate hp after damage deduction
	hp -= damage;

	cout << "\n" << setw(5) << left << " " << GetNameOfEntity(ent_Guard) << " has taken " << damage << " points of damage" << endl;

	//check to see if enemy is still alive
	if(hp > 0)
	{
		return false;
	}
	else if (hp <= 0)
	{
		DeathCry();
		//make sure hp is not negative
		hp = 0;
		return true;
	}
}

//create enemy taunt
void Guardsman::Taunt()
{
	//random number
	int random = rand()%4;
	
	if(random == 0)
	{
		cout << "\n" << GetNameOfEntity(ent_Guard) << ": I will defeat you!" << endl;
	}
	else if (random == 1)
	{
		cout << "\n" << GetNameOfEntity(ent_Guard) << ": You're no match for me" << endl;
	}
	else if (random == 2)
	{
		cout << "\n" << GetNameOfEntity(ent_Guard) << ": How pathetic!" << endl;
	}
	else if (random == 3)
	{
		cout << "\n" << GetNameOfEntity(ent_Guard) << ": Weakling!" << endl;
	}
}

//create taunt for special attack
void Guardsman::SpecialTaunt()
{
	cout << "\n" << GetNameOfEntity(ent_Guard) << ": It ends here!" << endl;
}

//create enemy death cry
void Guardsman::DeathCry()
{
	cout << "\n" << GetNameOfEntity(ent_Guard) << ": AAAAGGGGGHHHHH!!!!" << endl;
}